/*
 * @Author: your name
 * @Date: 2022-03-18 17:08:57
 * @LastEditTime: 2022-04-03 20:14:45
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \blog-system-front\src\Pages\Article\ariticleDetail\index.js
 */
import React, { useEffect, useState } from "react";
import ContentHeader from "@/Containers/ContentHeader";
import Main from "@/Containers/main";
import Editor from "md-editor-rt";
import { fetchArticleDetail } from "@/Services/article";
import { Button, Typography } from "antd";

const { Title } = Typography;
export default function AriticleDetail(props) {
  const { id } = props.match.params;
  const { state } = props.location.state;
  const [detailInfo, setDetailInfo] = useState({});
  useEffect(() => {
    fetchArticleDetail({
      articleId: id,
    }).then((res) => {
      setDetailInfo(res.content[0]);
    });
  }, []);
  return (
    <>
      <ContentHeader title="文章详情" backPath="/article/list">
        <Button type="primary">发布</Button>
      </ContentHeader>
      <Main>
        {state && <Title level={1}>{detailInfo.articleName}</Title>}
        <Editor modelValue={detailInfo.content} previewOnly={state} />
      </Main>
    </>
  );
}
